package org.example;

public class test8 {
    public static void main(String[] args) {
        /*//方法重载
        compare((byte)11, (byte)12);
        compare((short)1, (short)2);

    }
    public static void compare(byte a, byte b) {
        System.out.println(a == b);
    }
    public static void compare(short a, short b) {
        System.out.println(a == b);
    }
    public static void compare(int a, int b) {
        System.out.println(a == b);
    }
    public static void compare(long a, long b) {
        System.out.println(a == b);}*/

        /*
        //打印【11，22，33，44，55】
       1. int[] arr ={11, 22, 33, 44, 55} ;
        printArray(arr);
        public static void printArray(int[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length-1) {
                System.out.print(arr[i] + "]");
            } else {
                System.out.print(arr[i] + ",");
            }
        }
        2.int[] arr ={11, 22, 33, 44, 55} ;
          String str=arrtoString(arr);

          piblic staic String arrtoString(int[] arr) {
            StringBuilder sb = new StringBuilder();
            sb.append("[");
            for(int i=0;i<arr.length();i++){
               if(i==arr.length()-1){
                  sb.append(arr[i]);
                  }else{
                  sb.append(arr[i]).append(",");
                 }
           }
           sb.append("]");
           return sb.toString();
        }
        3.int [] arr ={11, 22, 33, 44, 55} ;
        //创建字符串拼接器 分隔号，开始符号，结束符号
        StringJoine sj=new StringJoine(",","[","]");
        for(int i=0;i<arr.length();i++){
           sj.add(arr[i]);
      }
        String str=sj.toSting();
        System.out.println(str);
        int len=sj.length();
        System.out.println(len);
        */
       /* //求数组的最大值
        int[] arr = {11, 22, 33, 44, 55};
        int max = getMax(arr);
        System.out.println(max);
    }
    public static int getMax(int[] arr) {
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
        }
        return max;*/
        //判断一个数字是否在数组中
        int[] arr = {11, 22, 33, 44, 55};
        boolean flag = contains(arr, 33);
        System.out.println(flag);
    }
    public static boolean contains(int[] arr, int value) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == value) {
                return true;
            }
        }
        return false;
    }
}